/*
 * @FilePath: /fxfzywpt/src/utils/matchProvince.js
 * @Description:
 */
import { iServerHttp, getGridLayer, getChinaBaseFeature } from '@/map/projMap.js';
export async function getTileLayerByCode(code, map) {
  let layer = null;
  let url = '';
  url = matchProviceUrlByCode(code);
  if (url) {
    layer = await getGridLayer(url);
  }
  layer.set('id', 'province');
  return layer;
}
export async function getTileLayerByName(proviceName, map) {
  let layer = null;
  let url = '';
  url = matchProviceUrl(proviceName);
  if (url) {
    layer = await getGridLayer(url);
  }
  layer.set('id', 'province');
  return layer;
}
export function matchProviceUrl(proviceName) {
  let url = '';
  url = matchData[proviceName];
  return url;
}
export function matchProviceUrlByCode(code) {
  let url = '';
  url = matchDataByCode[code];
  return url;
}
export async function getProviceFeature(proviceName) {
  let features = await getChinaBaseFeature();
  let proviceFeature = null;
  proviceFeature = features.find((feature) => {
    return feature.get('name') == proviceName;
  });
  return proviceFeature;
}
export async function getProviceFeatureByCode(code) {
  let features = await getChinaBaseFeature();
  let proviceFeature = null;
  proviceFeature = features.find((feature) => {
    return feature.get('adcode') == code;
  });
  return proviceFeature;
}
const matchData = {
  北京市: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_11_beijing@datacenter`,
  天津市: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_12_tianjin@datacenter`,
  河北省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_13_hebei@datacenter`,
  山西省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_14_shanxi@datacenter`,
  内蒙古自治区: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_15_neimeng@datacenter`,
  辽宁省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_21_liaoning@datacenter`,
  吉林省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_22_jilin@datacenter`,
  黑龙江省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_23_heilongjiang@datacenter`,
  上海市: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_31_shanghai@datacenter`,
  江苏省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_32_jiangsu@datacenter`,
  浙江省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_33_zhejiang@datacenter`,
  安徽省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_34_anhui@datacenter`,
  福建省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_35_fujian@datacenter`,
  江西省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_36_jiangxi@datacenter`,
  山东省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_37_shandong@datacenter`,
  河南省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_41_henan@datacenter`,
  湖北省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_42_hubei@datacenter`,
  湖南省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_43_hunan@datacenter`,
  广东省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_44_guangdong@datacenter`,
  广西壮族自治区: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_45_guangxi@datacenter`,
  海南省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_46_hainan@datacenter`,
  重庆市: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_50_chongqing@datacenter`,
  四川省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_51_sichuan@datacenter`,
  贵州省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_52_guizhou@datacenter`,
  云南省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_53_yunnan@datacenter`,
  西藏自治区: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_54_xizang@datacenter`,
  陕西省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_61_shannxi@datacenter`,
  甘肃省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_62_gansu@datacenter`,
  青海省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_63_qinghai@datacenter`,
  宁夏回族自治区: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_64_ningxia@datacenter`,
  新疆维吾尔自治区: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_65_xinjiang@datacenter`,
  台湾省: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_71_taiwan@datacenter`,
};
const matchDataByCode = {
  110000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_11_beijing@datacenter`,
  120000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_12_tianjin@datacenter`,
  130000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_13_hebei@datacenter`,
  140000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_14_shanxi@datacenter`,
  150000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_15_neimeng@datacenter`,
  210000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_21_liaoning@datacenter`,
  220000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_22_jilin@datacenter`,
  230000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_23_heilongjiang@datacenter`,
  310000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_31_shanghai@datacenter`,
  320000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_32_jiangsu@datacenter`,
  330000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_33_zhejiang@datacenter`,
  340000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_34_anhui@datacenter`,
  350000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_35_fujian@datacenter`,
  360000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_36_jiangxi@datacenter`,
  370000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_37_shandong@datacenter`,
  410000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_41_henan@datacenter`,
  420000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_42_hubei@datacenter`,
  430000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_43_hunan@datacenter`,
  440000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_44_guangdong@datacenter`,
  450000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_45_guangxi@datacenter`,
  460000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_46_hainan@datacenter`,
  500000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_50_chongqing@datacenter`,
  510000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_51_sichuan@datacenter`,
  520000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_52_guizhou@datacenter`,
  530000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_53_yunnan@datacenter`,
  540000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_54_xizang@datacenter`,
  610000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_61_shannxi@datacenter`,
  620000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_62_gansu@datacenter`,
  630000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_63_qinghai@datacenter`,
  640000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_64_ningxia@datacenter`,
  650000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_65_xinjiang@datacenter`,
  710000: `/iserver/services/map-datacenter/rest/maps/district_boundary_city_71_taiwan@datacenter`,
};
